﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework05
{
    public class OrderItem
    {
        public string Pname { get; set; }   //商品名
        public int Pnum { get; set; }   //商品数量
        public double TPrice
        {
            get
            {
                return cargos.GetPrice(Pname) * Pnum;
            }
            set
            {
                this.TPrice = value;
            }
        }
        public double SPrice
        {
            get
            {
                return cargos.GetPrice(Pname);
            }
            set
            {
                this.SPrice = value;
            }
        }

        Cargos cargos = new Cargos();
        public override bool Equals(object obj)
        {
            if (obj is OrderItem o)
            {
                return Pname == o.Pname;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return Pname.GetHashCode();
        }

        public override string ToString()
        {
            TPrice = cargos.GetPrice(Pname) * Pnum;
            return $"商品：{Pname} 数量：{Pnum} 价格：{TPrice}";
        }
    }
}
